#pragma once


#include "AbstractDataManager.h"

struct Article
{
	Article()
	{
		iHits = 0;
		iLevel = 0;
		dtTimeCreated = CTime::GetCurrentTime();
		dtTimeEdit = CTime::GetCurrentTime();
		dtTimeRead = CTime::GetCurrentTime();
		iLabID = 0;
	}
	Article(int id,int classID,const CString& sTitle,const CString& sContent,const CString& sCreator,const CString& sBookMark,const CString& sType)
		: iID(id),iClassID(classID),strTitle(sTitle),strContent(sContent),strCreator(sCreator),strBookMark(sBookMark),strType(sType)
	{
		iHits = 0;
		iLevel = 0;
		dtTimeCreated = CTime::GetCurrentTime();
		dtTimeEdit = CTime::GetCurrentTime();
		dtTimeRead = CTime::GetCurrentTime();
		iLabID = 0;
	}
	int			iID;
	int			iClassID;
	CString		strTitle;
	CString		strContent;
	CString		strCreator;
	CString		strAuthor;
	CString		strEditor;
	CString		strBookMark;
	int			iHits;
	int			iLevel;
	CTime		dtTimeCreated;
	CTime		dtTimeEdit;
	CTime		dtTimeRead;
	int			iLabID;
	CString		strType;
	CString		strKeyWords;
};
struct Tags
{
	CString		strTag;
	int			nCount;
	int			nTag;
};

typedef CAtlList<Tags*> TagList;
typedef CAtlList<Article*> ArticleList;
class CArticleManager: public CAbstractDataManager
{
public:
	CArticleManager(void);
	virtual ~CArticleManager(void);
public:
	int Add(const Article& art) ;
	int Delete(const int iID)  ;
	int Update(const Article& art) ;
	Article* GetArticle(const int iID);
	Article& GetArticle(){return m_Art;}
	int SetHits(const int iID) ;
	int SetLevel(const int iID,const int iLevel) ;
	int SetTimeRead(const int iID,const CTime& tTimeRead);
	int MoveTo(const int iClassID,const int iID);
	ArticleList* GetArticleList(const int iClassID);
	ArticleList* SearchArticleList(const CString strSearch);
	int SetKeyWords(const int nID,const CString strKeyWords);
	int SetAuthor(const int nID,const CString strAuthor);
	int SetBookmark(const int nID,const CString strRemark);
	int SetCreateDt(const int nID,const CTime& tCreate);
	int	AddTag(const int nID,const int nTagId);
	int AddTag(const int nID,const CString strTag);
	int CreateTag(const CString strTag);
	int RenameTag(const int nTagID,const CString strTag);
	int DeleteTag(const int nTagID);
	TagList* GetTags();
	TagList* GetAllTags();
	ArticleList* GetArticleListByTag(const int nTagID);
	CSimpleArray<int> GetArtTagList(const int nID);
private:
	Article m_Art;
};

